<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>登录 - 粮食收购大数据平台</title>
    <!-- Vue 3 -->
    <script src="https://unpkg.com/vue@3/dist/vue.global.js"></script>
    <!-- Element Plus -->
    <link rel="stylesheet" href="https://unpkg.com/element-plus/dist/index.css">
    <script src="https://unpkg.com/element-plus/dist/index.full.js"></script>
    <!-- Font Awesome -->
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
    <style>
        /* 基础样式设置 */
        body {
            margin: 0;
            padding: 0;
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            min-height: 100vh;
            font-family: 'Helvetica Neue', Helvetica, 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', '微软雅黑', Arial, sans-serif;
            display: flex;
            justify-content: center;
            align-items: center;
        }
        
        /* 登录容器样式 */
        .login-container {
            width: 100%;
            max-width: 400px;
            padding: 20px;
        }
        
        /* 登录卡片样式 */
        .login-card {
            background: rgba(255, 255, 255, 0.95);
            border-radius: 15px;
            box-shadow: 0 15px 35px rgba(0, 0, 0, 0.1);
            overflow: hidden;
            backdrop-filter: blur(10px);
        }
        
        /* 头部样式 */
        .login-header {
            text-align: center;
            padding: 40px 30px 30px;
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            color: white;
        }
        
        .company-logo {
            width: 60px;
            height: 60px;
            margin: 0 auto 15px;
            border-radius: 50%;
            overflow: hidden;
            border: 3px solid rgba(255, 255, 255, 0.3);
        }
        
        .company-logo img {
            width: 100%;
            height: 100%;
            object-fit: cover;
        }
        
        .login-title {
            margin: 0 0 5px 0;
            font-size: 24px;
            font-weight: 500;
        }
        
        .login-subtitle {
            margin: 0;
            font-size: 14px;
            opacity: 0.9;
        }
        
        /* 表单内容样式 */
        .login-content {
            padding: 30px;
        }
        
        .form-item {
            margin-bottom: 20px;
        }
        
        .login-btn {
            width: 100%;
            height: 45px;
            font-size: 16px;
            border-radius: 8px;
        }
        
        /* 返回链接样式 */
        .back-link {
            text-align: center;
            margin-top: 20px;
        }
        
        .back-link a {
            color: #667eea;
            text-decoration: none;
            font-size: 14px;
            transition: color 0.3s;
        }
        
        .back-link a:hover {
            color: #764ba2;
            text-decoration: underline;
        }
    </style>
</head>
<body>
    <div id="app">
        <div class="login-container">
            <div class="login-card">
                <!-- 登录头部 -->
                <div class="login-header">
                    <div class="company-logo">
                        <img src="logo.png" alt="新疆奎木星测控技术有限公司">
                    </div>
                    <h1 class="login-title">粮食收购大数据平台</h1>
                    <p class="login-subtitle">新疆奎木星测控技术有限公司</p>
                </div>

                <!-- 登录表单 -->
                <div class="login-content">
                    <el-form :model="loginForm" :rules="rules" ref="loginFormRef">
                        <!-- 用户名输入框 -->
                        <div class="form-item">
                            <el-input
                                v-model="loginForm.username"
                                placeholder="请输入用户名"
                                size="large"
                                clearable
                            >
                                <template #prefix>
                                    <i class="fas fa-user"></i>
                                </template>
                            </el-input>
                        </div>
                        
                        <!-- 密码输入框 -->
                        <div class="form-item">
                            <el-input
                                v-model="loginForm.password"
                                type="password"
                                placeholder="请输入密码"
                                size="large"
                                show-password
                                clearable
                                @keyup.enter="handleLogin"
                            >
                                <template #prefix>
                                    <i class="fas fa-lock"></i>
                                </template>
                            </el-input>
                        </div>
                        
                        <!-- 登录按钮 -->
                        <el-button 
                            type="primary" 
                            class="login-btn"
                            :loading="loading"
                            @click="handleLogin"
                        >
                            <i class="fas fa-sign-in-alt"></i>
                            {{ loading ? '登录中...' : '登录' }}
                        </el-button>
                    </el-form>
                    
                    <!-- 返回首页链接 -->
                    <div class="back-link">
                        <a href="index.html">
                            <i class="fas fa-arrow-left"></i> 返回首页
                        </a>
                    </div>
                </div>
            </div>
        </div>
    </div>

<script>
        const { createApp } = Vue;
        const { ElMessage, ElMessageBox } = ElementPlus;

        createApp({
            data() {
                return {
                    loading: false,
                    loginForm: {
                        username: '',
                        password: ''
                    },
                    rules: {
                        username: [
                            { required: true, message: '请输入用户名', trigger: 'blur' }
                        ],
                        password: [
                            { required: true, message: '请输入密码', trigger: 'blur' }
                        ]
                    }
                }
            },
            methods: {
                async handleLogin() {
                    // 表单验证
                    try {
                        await this.$refs.loginFormRef.validate();
                    } catch (error) {
                        return;
                    }

                    this.loading = true;
                    
                    try {
                        // 模拟登录API调用
                        await new Promise(resolve => setTimeout(resolve, 1500));
                        
                        // 简单的演示账号验证
                        if (this.loginForm.username === 'admin' && this.loginForm.password === '123456') {
                            ElMessage.success('登录成功！');
                            
                            // 保存登录状态
                            const userInfo = {
                                username: this.loginForm.username,
                                loginTime: new Date().toISOString()
                            };
                            localStorage.setItem('userInfo', JSON.stringify(userInfo));
                            
                            // 跳转到首页，带上登录标识参数
                            setTimeout(() => {
                                window.location.href = 'index.html?from=login';
                            }, 1000);
                        } else {
                            ElMessage.error('用户名或密码错误（演示账号：admin/123456）');
                        }
                        
                    } catch (error) {
                        ElMessage.error('登录失败，请稍后重试');
                    } finally {
                        this.loading = false;
                    }
                }
            }
        }).use(ElementPlus).mount('#app');
    </script>
</body>
</html>